package demoMod.stsconsole.monsters.exordium;

import demoMod.stsconsole.dungeons.AbstractDungeon;
import demoMod.stsconsole.helpers.DamageInfo;
import demoMod.stsconsole.monsters.AbstractMonster;
import demoMod.stsconsole.powers.StrengthPower;

public class JawWorm extends AbstractMonster {
    public static final String ID = "JawWorm";
    private final boolean hardMode;

    public JawWorm(boolean hardMode) {
        super(ID);
        this.hardMode = hardMode;
        if (this.hardMode) {
            this.firstMove = false;
        }
        setHp(40, 44);
        this.damage.add(new DamageInfo(11, this));
        this.damage.add(new DamageInfo(7, this));
    }

    public void usePreBattleAction() {
        if (this.hardMode) {
            applyPower(this, new StrengthPower(this, 5));
            gainBlock(6);
        }
    }

    @Override
    protected void getMove(int aiRng) {
        if (this.firstMove) {
            this.firstMove = false;
            setMove(1, Intent.ATTACK, this.damage.get(0));
        } else {
            if (aiRng < 25) {
                if (this.lastMove(1)) {
                    if (AbstractDungeon.aiRng.nextBoolean(0.5625F)) {
                        setMove(2, Intent.DEFEND_BUFF, this.monsterStrings.get(1));
                    } else {
                        setMove(3, Intent.ATTACK_DEFEND, this.damage.get(1));
                    }
                } else {
                    setMove(1, Intent.ATTACK, this.damage.get(0));
                }
            } else if (aiRng < 55) {
                if (this.lastTwoMoves(3)) {
                    if (AbstractDungeon.aiRng.nextBoolean(0.357F)) {
                        setMove(1, Intent.ATTACK, this.damage.get(0));
                    } else {
                        setMove(2, Intent.DEFEND_BUFF, this.monsterStrings.get(1));
                    }
                } else {
                    setMove(3, Intent.ATTACK_DEFEND, this.damage.get(1));
                }
            } else if (this.lastMove(2)) {
                if (AbstractDungeon.aiRng.nextBoolean(0.416F)) {
                    this.setMove(1, Intent.ATTACK, this.damage.get(0));
                } else {
                    this.setMove(3, Intent.ATTACK_DEFEND, this.damage.get(1));
                }
            } else {
                setMove(2, Intent.DEFEND_BUFF, this.monsterStrings.get(1));
            }
        }
    }

    @Override
    public void takeTurn() {
        switch (this.nextMove) {
            case 1:
                this.defaultTarget.damage(this.damage.get(0));
                break;
            case 2:
                this.applyPower(this, new StrengthPower(this, 4));
                this.gainBlock(9);
                break;
            case 3:
                this.defaultTarget.damage(this.damage.get(1));
                this.gainBlock(6);
                break;
        }
        rollMove();
    }
}
